package com.cskaoyan.config;

import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;

/**
 * @author
 * @date 2020/12/7 16:43
 */
public class CustomSessionManager extends DefaultWebSessionManager {

    @Override
    protected Serializable getSessionId(ServletRequest srequest, ServletResponse response) {
        HttpServletRequest request = (HttpServletRequest) srequest;
        String adminHeader = request.getHeader("X-cskaoyan-mall-Admin-Token");
        if (adminHeader != null && !"".equals(adminHeader))
        {
            return adminHeader;
        }
        String wxHeader = request.getHeader("X-Litemall-Token");
        if (wxHeader != null && !"".equals(wxHeader))
        {
            return wxHeader;
        }

        return super.getSessionId(request, response);
    }
}
